Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eventgenerator): Integrate cf api with event generator #3357

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

bonzofenix
Copy link
Contributor

@bonzofenix bonzofenix commented Nov 21, 2024

The event generator must allow requests from incoming API component running on CF. This PR introduces handling allowed space and org GUID through XFCC authentication.

Key Changes:

  • Public API sends instance identity certificate to event generator when CF_INSTANCE_CERT is available (when running on CF).
  • Added CfInstanceCert field to the eventgenerator#Config model.
  • Updated the XFCCAuthMiddleware:
    • fix an issue when parsing certificate space and org GUID from cert.
    • Fix an issue when parsing the XFCC header.
  1. Code Refactoring:
  • src/autoscaler/integration/integration_golangapi_eventgenerator_test.go
  • src/autoscaler/api/publicapiserver/public_api_handler.go

@bonzofenix bonzofenix changed the base branch from main to add-cf-endpoint-to-eventgenerator November 21, 2024 15:03
@bonzofenix bonzofenix marked this pull request as draft November 21, 2024 15:03
@bonzofenix bonzofenix force-pushed the integrate-cf-api-with-eventgenerator branch 6 times, most recently from 87801c3 to 2cdfad3 Compare November 25, 2024 13:44
@bonzofenix bonzofenix force-pushed the add-cf-endpoint-to-eventgenerator branch from 0607dfe to 05c7cc4 Compare November 25, 2024 14:49
@bonzofenix bonzofenix force-pushed the integrate-cf-api-with-eventgenerator branch from 2cdfad3 to 0108dda Compare November 25, 2024 14:50
@bonzofenix bonzofenix self-assigned this Nov 25, 2024
@bonzofenix bonzofenix force-pushed the integrate-cf-api-with-eventgenerator branch from 0108dda to 12a4687 Compare November 26, 2024 10:07
@bonzofenix bonzofenix force-pushed the add-cf-endpoint-to-eventgenerator branch 2 times, most recently from 40028b5 to 00083e4 Compare November 28, 2024 10:09
@bonzofenix bonzofenix force-pushed the integrate-cf-api-with-eventgenerator branch 3 times, most recently from 0100ccb to 53fbafc Compare November 28, 2024 13:40
@bonzofenix bonzofenix changed the title (feat) Integrate cf api with eventgenerator feat(eventgenerator): Integrate cf api with event generator Nov 29, 2024
@bonzofenix bonzofenix marked this pull request as ready for review November 29, 2024 14:44
Base automatically changed from add-cf-endpoint-to-eventgenerator to main November 30, 2024 03:08
Copy link
Member

@silvestre silvestre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must not set the XFCC header ourselves, see the dedicated comment.

src/autoscaler/api/publicapiserver/public_api_handler.go Outdated Show resolved Hide resolved
src/autoscaler/api/publicapiserver/public_api_handler.go Outdated Show resolved Hide resolved
src/autoscaler/api/publicapiserver/public_api_handler.go Outdated Show resolved Hide resolved
src/autoscaler/api/publicapiserver/public_api_handler.go Outdated Show resolved Hide resolved
src/autoscaler/api/publicapiserver/public_api_handler.go Outdated Show resolved Hide resolved
 - handle CF_INSTANCE_CERT and CF_INSTANCE_KEY
 - Remove `CfInstanceCert` from `Config` struct and related code
 - Generate RSA keys and certificates for testing in `api_test.go` and `config_test.go`
 - Set environment variables for instance keys and certs in tests
 - Update `config#configureEventGenerator` to use environment variables for TLS config
 - Remove unused `auth` import and related code in `public_api_handler.go`
 - Create `MaterializeContentInFile` function in `configutil` for file operations
 - Add `GenerateClientCertWithPrivateKey` and `GenerateClientKeyWithPrivateKey` in `testhelpers`
 • Eliminate GetCfInstanceCert method and associated environment variable usage.
 • Update tests to reflect removal of CF_INSTANCE_CERT handling.
@bonzofenix bonzofenix requested a review from silvestre December 15, 2024 20:32
 - Make `generate-fakes` target `.PHONY` in Makefile
 - Remove dependency of `generate-fakes` from `testsuite` target
 - Simplify `configureEventGenerator` function by directly setting `CertFile` and `KeyFile` from environment variables
 - Update tests to reflect changes in `configureEventGenerator` and remove unnecessary file creation for `CF_INSTANCE_CERT` and `CF_INSTANCE_KEY`
@bonzofenix bonzofenix force-pushed the integrate-cf-api-with-eventgenerator branch 4 times, most recently from 4ec6bdc to 3f43eba Compare December 18, 2024 23:22
@bonzofenix bonzofenix force-pushed the integrate-cf-api-with-eventgenerator branch from 3f43eba to bf9e05e Compare December 18, 2024 23:26
@bonzofenix bonzofenix force-pushed the integrate-cf-api-with-eventgenerator branch from 9331fbe to f5b31e8 Compare December 19, 2024 15:57
bonzofenix and others added 6 commits December 19, 2024 13:24
…iration

 • Changed certExpiration from a pointer to a non-pointer time.Time type.
 • Updated GetCertExpiration and certificateExpiringWithin methods to handle the non-pointer type.
 • Removed unnecessary pointer dereferences in httpclient_test.go.
@bonzofenix bonzofenix enabled auto-merge (squash) December 19, 2024 21:55
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
8.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants